<?php
class FunduserServer {
	public function pagingBySearch($where="",$order='',$numberEachPage = 10){
		$count = HttpDaoManager::getFunduserDao()->searchNumber($where);
		$page = new Page($count, $numberEachPage);
		$limit[0]= $page->which;
		$limit[1]=$numberEachPage;
		$list = HttpDaoManager::getFunduserDao()->searchList($where,$order, $limit);
		$page1= $page->returnPage("?".ClassManager::getToos()->combinationGet('page')."&page=");
		$data['list'] =$list;
		$data['page'] = $page1;
		return $data;
	}
	
	
	public function pagingForsumsale($where="",$order='',$numberEachPage = 10){
		$count = HttpDaoManager::getFunduserDao()->searchNumberForsumsale($where);
		$page = new Page($count, $numberEachPage);
		$limit[0]= $page->which;
		$limit[1]=$numberEachPage;
		$list = HttpDaoManager::getFunduserDao()->searchListForsumsale($where,$order, $limit);
		$page1= $page->returnPage("?".ClassManager::getToos()->combinationGet('page')."&page=");
		$data['list'] =$list;
		$data['page'] = $page1;
		return $data;
	}
	
	
	public function pagingFordetailsale($where="",$order='',$numberEachPage = 10){
		$count = HttpDaoManager::getFunduserDao()->searchNumberFordetailsale($where);
		$page = new Page($count, $numberEachPage);
		$limit[0]= $page->which;
		$limit[1]=$numberEachPage;
		$list = HttpDaoManager::getFunduserDao()->searchListFordetailsale($where,$order, $limit);
		$page1= $page->returnPage("?".ClassManager::getToos()->combinationGet('page')."&page=");
		$data['list'] =$list;
		$data['page'] = $page1;
		return $data;
	}


	public function pagingForRecommenddetailsale($where="",$order='',$numberEachPage = 10){
		$count = HttpDaoManager::getFunduserDao()->searchNumberForRecommenddetailsale($where);
		$page = new Page($count, $numberEachPage);
		$limit[0]= $page->which;
		$limit[1]=$numberEachPage;
		$list = HttpDaoManager::getFunduserDao()->searchListForRecommenddetailsale($where,$order, $limit);
		$page1= $page->returnPage("?".ClassManager::getToos()->combinationGet('page')."&page=");
		$data['list'] =$list;
		$data['page'] = $page1;
		return $data;
	}
	
	
	public function add($data){
		if (empty($data['email'])){
			return ERROR_CODE_ONE;
		}

		if(!empty($data['phone'])){
			$userdata = HttpDaoManager::getFunduserDao()->getByPhone($data['phone']);
			if (!empty($userdata)){
				return ERROR_CODE_FIVE;
			}
		}
	
		$data['add_time']   = time();
		$data['add_user'] = $_SESSION['admin']['name'];
		HttpDaoManager::getFunduserDao()->add($data);//zhuce
		return true;
	}
	
	public function update(){
		$msg = Common::_t('data_edit_success');
		HttpDaoManager::getFunduserDao()->update($_POST,$_POST['id']);
		ClassManager::getToos()->msgbox($msg,'funduser_lists.html');
	}
	
	public function cacluteSumRecommendOrderFund($where){
		return HttpDaoManager::getFunduserDao()->searchRecomendListForsumsale($where);
	}
}
?>